<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<script type="text/javascript">
	function searchCheck(){
		if(document.search.keyWord.value==''){
			alert('검색어를 입력하세요.');
			document.search.keyWord.focus();
			return false;
		}
	}
</script>
<form action="qboardlist.do" name="search" method="get" onsubmit="return searchCheck()">
<table width="900" border="0" cellspacing="0" cellpadding="2"> 
	<tr>
		<td colspan="6">
			<img src="../images/go.png">
		</td>
	</tr>
	<tr bgcolor="#fadded">
		<th width="50">번호</th>
		<th width="280">제목</th>
		<th width="90">글쓴이</th>
		<th width="110">날짜</th>
		<th width="60">조회수</th>
		<th width="60">답변상태</th>
	</tr>
	<tr bgcolor="#e10380">
		<td height="1" colspan="6"></td>
	</tr>
	<!-- 리스트 불러오는 부분 -->
	<c:forEach var="article" items="${list}">
		<tr> 
			<td align="center">
				${number}
				<c:set var="number" value="${number-1}"/>
			</td>
			<td align="center">
				<a href="boardqnadetail.do?bq_num=${article.bq_num}">${article.bq_title}</a>
			</td>
			<td align="center">${article.userid}</td>
			<td align="center"><fmt:formatDate value="${article.bq_writeday}" pattern="yyyy년MM월dd일"/></td>
			<td align="center">${article.bq_readcnt}</td>
			<td align="center">${article.bq_status}</td>
		</tr>
	</c:forEach>
	<!-- 리스트가 없으면 출력 -->
	<c:if test="${count == 0}">
		<tr align="center">
			<td colspan="6">등록된 게시물이 없습니다.</td>
		</tr>
			<tr bgcolor="#e10380">
			<td height="1" colspan="6"></td> 
		</tr>
	</c:if>
	<tr>
		<td align="center" colspan="6">${pagingHtml}</td>
	</tr>
</table>
<table width="900" align="center" border="0" >
	<tr> 
		<td align="center">
			<select name="keyField">
				<option value="title">제목</option>
				<option value="writer">이름</option>
				<option value="content">내용</option>
				<option value="all">전체</option> 
			</select>
		
			<input type="text" size="23" name="keyWord" placeholder="검색할 단어를 입력하세요"> 
		
			<input type="submit" value="찾기">
		</td>
	</tr> 
	<tr>
		<td align="right" colspan="5">
			<input type="button" value="글쓰기" class="inputb"
			       onclick="location.href='qboardinsert.do'">
		</td>
	</tr>                                  
</table>
</form>